package com.heima.wemedia.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.mapper.WemediaMapper;
import com.heima.wemedia.service.WemediaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/user")
@Api(value = "自媒体controller",tags = "自媒体controller")
public class WemediaVController {
    @Autowired
    private WemediaService wemediaService;

    @ApiOperation("根据名称查询自媒体用户信息")
    @GetMapping("/findByName/{name}")
    public ResponseResult getByName(@PathVariable("name") String name){
        return ResponseResult.okResult(wemediaService.getOne(Wrappers.<WmUser>lambdaQuery().eq(WmUser::getName,name)));
    }
    @ApiOperation("根据名称保存自媒体用户信息")
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmUser wmUser){
         wemediaService.save(wmUser);
        return ResponseResult.okResult(wmUser);
    }

}
